Skip to content

Conversation

@SylvainJuge
Copy link
Contributor

@SylvainJuge SylvainJuge commented May 21, 2025

Migrate the following http clients instrumentations to be indy-ready:

  • async-http-client
  • google-http-client
  • java-http-client
  • jetty-httpclient

part of #13031

@SylvainJuge SylvainJuge self-assigned this May 21, 2025
@SylvainJuge SylvainJuge changed the title more http clients indy migration migrate more http clients to indy-ready May 23, 2025
@SuppressWarnings("unused")
public static class JettyHttpClient12SendAdvice {

public static class AdviceLocals {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[for reviewer] when leaving it as "locals storage" only, we keep the AdviceLocals class name, we could also use the AdviceScope like in other places for consistency.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to keep it as AdviceLocals in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you on keeping the naming AdviceLocals here when it's just a way to carry the previously advice-local variables, what I meant was more: should we make this an AdviceScope, including moving parts of the logic from advice code ?

public final Context context;
public final Scope scope;

public AdviceLocals(Context context, Scope scope) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[for reviewer] same here we could migrate this to AdviceScope for better consistency with other changes.

@SylvainJuge SylvainJuge marked this pull request as ready for review May 26, 2025 08:09
@SylvainJuge SylvainJuge requested a review from a team as a code owner May 26, 2025 08:09
@SuppressWarnings("unused")
public static class JettyHttpClient12SendAdvice {

public static class AdviceLocals {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to keep it as AdviceLocals in this case.

Comment on lines 114 to 137
public boolean end(@Nullable HttpResponse<?> response, @Nullable Throwable throwable) {
// non-null call depth only used for async to prevent recursion
if (callDepth != null) {
if (callDepth.decrementAndGet() > 0) {
// async end nested call
return false;
}

scope.close();
if (throwable != null) {
// async end with exception: ending span and no wrapping needed
instrumenter().end(context, request, response, throwable);
return false;
}

// async end without exception:
return true;
}

// synchronous end
scope.close();
instrumenter().end(context, httpRequest, httpResponse, throwable);
instrumenter().end(context, request, response, throwable);
return false;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

making a single end method requires to handle both the synchronous and asynchronous cases here, we use the fact that callDepth is null when doing synchronous calls and not when doing asynchronous calls.

@Advice.Local("otelScope") Scope scope) {
if (scope == null) {
@Advice.Enter @Nullable AdviceLocals locals) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

SylvainJuge and others added 8 commits May 27, 2025 18:03
…nt/src/main/java/io/opentelemetry/javaagent/instrumentation/jetty/httpclient/v12_0/JettyClient12ResponseListenersInstrumentation.java

Co-authored-by: Lauri Tulmin <[email protected]>
…nt/src/main/java/io/opentelemetry/javaagent/instrumentation/jetty/httpclient/v12_0/JettyHttpClient12Instrumentation.java

Co-authored-by: Lauri Tulmin <[email protected]>
…nt/src/main/java/io/opentelemetry/javaagent/instrumentation/jetty/httpclient/v12_0/JettyHttpClient12Instrumentation.java

Co-authored-by: Lauri Tulmin <[email protected]>
@trask trask merged commit 8081608 into open-telemetry:main May 29, 2025
88 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants